package com.flyduck.vueshop.product.remote.controller;

import com.flyduck.vueshop.common.core.lang.Result;
import com.flyduck.vueshop.common.sotoken.annotation.InnerAuth;
import com.flyduck.vueshop.product.remote.service.RemoteSkuStockService;
import com.flyduck.vueshop.product.vo.RemoteSkuStockReduceReqVO;
import com.flyduck.vueshop.product.vo.RemoteSkuStockReleaseReqVO;
import com.flyduck.vueshop.product.vo.RemoteSkuStockRespVO;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * RemoteSkuStockController
 * </p>
 *
 * @author flyduck
 * @since 2024-07-15
 */
@RestController
@RequestMapping("/product/remote/skuStock")
public class RemoteSkuStockController {

    @Resource
    private RemoteSkuStockService remoteSkuStockService;

    @InnerAuth
    @PostMapping("/batchReduceSkuStock")
    public Result<Void> batchReduceSkuStock(@RequestBody List<RemoteSkuStockReduceReqVO> remoteSkuStockReduceReqVOList){
        remoteSkuStockService.batchReduceSkuStock(remoteSkuStockReduceReqVOList);
        return Result.success();
    }

    @InnerAuth
    @PostMapping("/batchReleaseSkuStock")
    public Result<Void> batchReleaseSkuStock(@RequestBody List<RemoteSkuStockReleaseReqVO> remoteSkuStockReleaseReqVOList){
        remoteSkuStockService.batchReleaseSkuStock(remoteSkuStockReleaseReqVOList);
        return Result.success();
    }

    @InnerAuth
    @GetMapping("/getSkuStock")
    public Result<RemoteSkuStockRespVO> getSkuStock(@RequestParam("productId") Long productId, @RequestParam("skuId") Long skuId){
        RemoteSkuStockRespVO remoteSkuStockRespVO = remoteSkuStockService.getSkuStock(productId,skuId);
        return Result.success(remoteSkuStockRespVO);
    }
}
